package zhongbo.java.air.dictionary.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;

import javax.validation.constraints.*;
import java.util.Date;
import java.io.Serializable;

/**
 * 机场信息表(AirAirport)实体类
 *
 * @author makejava
 * @since 2025-03-31 14:05:41
 */
@Data
@Builder

@AllArgsConstructor
@TableName("air_airport")
@ApiModel("机场信息")
public class AirAirport implements Serializable {
    /**
     * UUID 主键
     */
    @ApiModelProperty(value = "UUID 主键",example = "1")
    @TableId(type = IdType.ASSIGN_UUID)
    @NotNull(message = "UUID 主键不能为空")
    @Size(min = 1, max = 36, message = "UUID主键长度应在1到36个字符之间")
    private String id;
    /**
     * ICAO机场代码（如 ZBAA）
     */
    @ApiModelProperty(value = "ICAO机场代码",example = "ZBAB")
    @NotNull(message = "ICAO机场代码不能为空")
    @Size(min = 1, max = 4, message = "ICAO机场代码长度应在1到4个字符之间")
    @Pattern(regexp = "^[A-Z]{4}$", message = "ICAO机场代码必须是4个大写字母")
    private String icaoCode;
    /**
     * IATA代码（如 PEK）
     */
    @ApiModelProperty(value = "IATA代码",example = "PEE")
    @NotNull(message = "IATA代码不能为空")
    @Size(min = 1, max = 3, message = "IATA代码长度应在1到3个字符之间")
    @Pattern(regexp = "^[A-Z]{3}$", message = "IATA代码必须是3个大写字母")
    private String iataCode;
    /**
     * 机场全称
     */
    @ApiModelProperty(value = "机场全称",example = "kb")
    @NotNull(message = "机场全称不能为空")
    @Size(min = 1, max = 100, message = "机场全称长度应在1到100个字符之间")
    private String name;
    /**
     * 纬度（WGS84坐标系，小数点后6位）
     */
    @ApiModelProperty(value = "纬度",example = "12")
    @NotNull(message = "纬度不能为空")
    private Double latitude;
    /**
     * 经度（WGS84坐标系，小数点后6位）
     */
    @ApiModelProperty(value = "经度",example = "13")
    @NotNull(message = "经度不能为空")
    private Double longitude;
    /**
     * 状态（枚举值：OPERATIONAL-运行中, CLOSED-已关闭, RESTRICTED-限制运行）
     */
    @ApiModelProperty(value = "状态",example = "OPERATIONAL")
    @NotNull(message = "状态不能为空")
    @Size(min = 1, max = 20, message = "状态长度应在1到20个字符之间")
    @Pattern(regexp = "^(OPERATIONAL|CLOSED|RESTRICTED)$", message = "状态必须是 OPERATIONAL, CLOSED 或 RESTRICTED")

    private String status;
    /**
     * 时区（如 Asia/Shanghai）
     */
    @ApiModelProperty(value = "时区",example = "Asia/Shanghai")
    @NotNull(message = "时区不能为空")
    @Size(min = 1, max = 50, message = "时区长度应在1到50个字符之间")
    private String timezone;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间",example = "2025-03-31 15:19:25")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @NotNull(message = "创建时间不能为空")
    @PastOrPresent(message = "创建时间必须是过去或现在")
    private Date createTime;
    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间",example ="2025-04-11 15:19:25" )
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @NotNull(message = "更新时间不能为空")
    @PastOrPresent(message = "更新时间必须是过去或现在")

    private Date updateTime;

    // 修改默认构造函数，自动设置 createTime 和 updateTime
    public AirAirport() {
        this.createTime = new Date();
        this.updateTime = new Date();
    }

    // 新增构造函数，自动设置 createTime 和 updateTime
    public AirAirport(String id, String icaoCode, String iataCode, String name, Double latitude, Double longitude, String status, String timezone) {
        this.id = id;
        this.icaoCode = icaoCode;
        this.iataCode = iataCode;
        this.name = name;
        this.latitude = latitude;
        this.longitude = longitude;
        this.status = status;
        this.timezone = timezone;
        this.createTime = new Date();
        this.updateTime = new Date();
    }
}